# 2028 找出缺失的观测数据

class Solution:
    # def missingRolls(self, rolls: List[int], mean: int, n: int) -> List[int]:
    def missingRolls(self, rolls, mean: int, n: int):
        # length = n + len(rolls)
        # tol = mean * length
        # sum_n = tol - sum(rolls)
        # avg = sum_n // n
        # if sum_n / n > 6.0 or sum_n <= 0:
        #     return []
        # ret = [avg] * (n - 1)
        # ret.append(sum_n - avg * (n - 1))
        # return ret

        missingSum = mean * (n + len(rolls)) - sum(rolls)
        if not n <= missingSum <= n * 6:
            return []
        quotient, remainder = divmod(missingSum, n)
        return [quotient + 1] * remainder + [quotient] * (n - remainder)


s = Solution()
print(s.missingRolls([3, 2, 4, 3], 4, 2))
